# -*- coding:utf-8 -*-
"""
this file is the implementation of fuzzy clustering lyric-based song emotion detection
1 get all the affective lexicon, but, private, tense words, modifier
2 calculate the emotion of each sentence
3 clustering the sentence using fuzzy method here
"""

from lyricemo.utils import split_by_emoword
from commontool.privative import get_privative
from LyricStructure.pylyric.Lyric import Lyric #TODO, should move to common tools


def get_words(sen):
    # affective lexicon
    emo_list = split_by_emoword(sen)
    print "emo",
    for emo_dic in emo_list:
        if emo_dic.has_key('emo'):
            print ' [', emo_dic['w'], emo_dic['start'], emo_dic['end'], '] ',
    print ""

    # but, private, tense words
    privative_list =  get_privative(sen)
    print 'privative',
    for w,s,e in privative_list:
        print ' [',w,s,e,'] ',
    print ""

    # get those words here

    pass


def get_emotion(sen):
    w_l_list = get_words(sen)

    pass


def predict_6_svsm(lrc_str):
    l = Lyric()
    l.loadstr(lrc_str)
    l_list = l.getlinelist()
    
    for l_index,l_item in enumerate(l_list):
        line = l_item['content']
        print line
        get_words(line)
    pass

#run batch to static the result

if __name__ == "__main__":
    #sen = u"我爱北京天安门，不会伤心死了"
    #get_words(sen)
    mid = 2811
    lrc_str = open('/Users/wangxing/gd/lyrics/%s.lrc'%(mid)).read()
    predict_6_svsm(lrc_str.decode('gbk'))

